package net.ix.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.util.Log;

public class SimpleConnection{
	/**
	 * 常用网络连接
	 */
	private String _uri;
	
	public SimpleConnection(String uri){
		_uri = uri;
	}
	public String NetConn(){
    	URL url = null;
    	String result = "";
    	try {
			url = new URL(_uri);
		} catch (MalformedURLException e) {
			return e.getMessage();
		}
    	try
    	{
    		HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
    		
    		BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), "utf-8"));
    		
    		String inputLine = null;
    		
    		while ((inputLine = in.readLine()) != null) {
				result += inputLine + "\n";
			}
    		
	    	in.close();
			urlConn.disconnect();
    	}
    	catch(Exception e)
    	{
    		return e.getMessage();
    	}
    	Log.v("Net", result);
    	return result;
    }
}